/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package TimeRecording.tables;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Transient;

/**
 *
 * @author david
 */
@Embeddable
public class WorkingPatternPK implements Serializable {

    // <editor-fold defaultstate="collapsed" desc="Property Change Support">
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    } // </editor-fold>

    @Basic(optional = false)
    @Column(name = "employee_id")
    private int employeeId;

    @Basic(optional = false)
    @Column(name = "ordinal")
    private short patternIndex;

    public WorkingPatternPK() {
    }

    public WorkingPatternPK(int employeeId, short patternIndex) {
        this.employeeId = employeeId;
        this.patternIndex = patternIndex;
    }

    public int getEmployeeId() {
        return employeeId;
    }

    public void setEmployeeId(int employeeId) {
        int oldEmployeeId = this.employeeId;
        this.employeeId = employeeId;
        changeSupport.firePropertyChange("employeeId", oldEmployeeId, employeeId);
    }

    public short getPatternIndex() {
        return patternIndex;
    }

    public void setPatternIndex(short patternIndex) {
        short oldPatternIndex = this.patternIndex;
        this.patternIndex = patternIndex;
        changeSupport.firePropertyChange("patternIndex", oldPatternIndex, patternIndex);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (int) employeeId;
        hash += (int) patternIndex;
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof WorkingPatternPK)) {
            return false;
        }
        WorkingPatternPK other = (WorkingPatternPK) object;
        if (this.employeeId != other.employeeId) {
            return false;
        }
        if (this.patternIndex != other.patternIndex) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "desktopapplication1.persistence.WorkingPatternPK[employeeId=" + employeeId + ", periodIndex=" + patternIndex + "]";
    }
}